import Vue from "vue";
import VueRouter from "vue-router";
import Login from '@/views/login';
import Layout from '@/views/layout';
import Home from "@/views/home";
import Member from "@/views/member";
import Goods from "@/views/goods";
import Order from "@/views/order";
import totalType from "@/views/totalType";
import goodsType from "@/views/goodsType";
Vue.use(VueRouter);
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}
const routes = [
  {
    path: '/',
    name: 'layout',
    component: Layout,
    redirect: '/home',
    children: [
      {
        path: '/home',
        name: 'home',
        component: Home,
        meta:{title:'首页'}
      },
      {
        path: '/member',
        name: 'member',
        component: Member,
        meta:{title:'用户管理'}
      },
      {
        path: '/goods',
        name: 'goods',
        component: Goods,
        meta:{title:'商品管理'}
      },
      {
        path: '/order',
        name: 'order',
        component: Order,
        meta:{title:'订单管理'}
      },
      {
        path: '/totalType',
        name: 'totalType',
        component: totalType,
        meta:{title:'商品类型管理'}
      },
      {
        path: '/goodsType',
        name: 'goodsType',
        component: goodsType,
        meta:{title:'商品总类型管理'}
      }
    ]
  },
  {
    path: "/login",
    name: 'login',
    component: Login
  }
];

const router = new VueRouter({
  mode: "history",
  base: process.env.BASE_URL,
  routes
});

export default router;
